package com.floreantpos.model.dao;

import com.floreantpos.model.TicketItem;
import com.floreantpos.model.base.BaseTicketItem;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

public class TicketItemDAO extends BaseTicketItemDAO {

  /**
   * Default constructor. Can be used in place of getInstance()
   */
  public TicketItemDAO() {
  }
  
  public Boolean isMenuItemInTicketItem(Integer menuItemId) {
    Session session = null;

    try {
      session = getSession();
      Criteria criteria = session.createCriteria(getReferenceClass());
      criteria.add(Restrictions.eq(TicketItem.PROP_ITEM_ID, menuItemId));

      List list = criteria.list();
      if (list.size() <= 0) {
        return false;
      }

      return true;
    } finally {
      if (session != null && session.isOpen()) {
        closeSession(session);
      }
    }
  }  

}
